<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Tolc: app/admin/new_page/ajax_new_page.php Source File</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../resize.js"></script>
<script type="text/javascript" src="../../navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="../../tolc_logo.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">Tolc
   &#160;<span id="projectnumber">v 1.00</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.2 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="../../index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="../../pages.html"><span>Related&#160;Pages</span></a></li>
      <li class="current"><a href="../../files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="../../search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="../../search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="../../files.html"><span>File&#160;List</span></a></li>
      <li><a href="../../globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('d0/d3d/ajax__new__page_8php_source.html','../../');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">ajax_new_page.php</div>  </div>
</div><!--header-->
<div class="contents">
<a href="../../d0/d3d/ajax__new__page_8php.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;&lt;?php</div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;session_start();</div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;session_regenerate_id();</div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;</div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment">// prevent direct access</span></div>
<div class="line"><a name="l00006"></a><span class="lineno"><a class="code" href="../../d0/d3d/ajax__new__page_8php.html#ad847b1d5d75085490c4954a4b94521a1">    6</a></span>&#160;<a class="code" href="../../d2/d6e/ajax__about__form_8php.html#ad847b1d5d75085490c4954a4b94521a1">$isAjax</a> = isset($_SERVER[<span class="stringliteral">&#39;HTTP_X_REQUESTED_WITH&#39;</span>]) AND</div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;        strtolower($_SERVER[&#39;HTTP_X_REQUESTED_WITH&#39;]) === &#39;xmlhttprequest&#39;;</div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<a class="code" href="../../d2/d6e/ajax__about__form_8php.html#a41b422ef9d6a2d7fe4a25345ef237e77">if</a>(!<a class="code" href="../../d2/d6e/ajax__about__form_8php.html#ad847b1d5d75085490c4954a4b94521a1">$isAjax</a>) {</div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;        print <span class="stringliteral">&#39;Access denied - not an AJAX request...&#39;</span> . <span class="stringliteral">&#39; (&#39;</span> . __FILE__ . <span class="charliteral">&#39;)&#39;</span>;</div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;        exit;</div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;}</div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;</div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="comment">// check for logged in user</span></div>
<div class="line"><a name="l00014"></a><span class="lineno"><a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a6789533118de9ff4c41a9b4a73d6f02e">   14</a></span>&#160;<span class="keywordflow">if</span>(!isset(<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a395f20d5378de643ef8d64e86d6bba9a">$_SESSION</a>[<span class="stringliteral">&#39;username&#39;</span>])) {</div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;        print <span class="stringliteral">&#39;Access denied&#39;</span> . <span class="stringliteral">&#39; (&#39;</span> . __FILE__ . <span class="charliteral">&#39;)&#39;</span>;</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;        exit;</div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;}</div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;require_once <span class="stringliteral">&#39;../../conf/settings.php&#39;</span>;</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;require_once <a class="code" href="../../de/dc4/settings_8dist_8php.html#af21c418e4c577deb3a9ea7299156ae35">$tolc_conf</a>[<span class="stringliteral">&#39;project_dir&#39;</span>] . <span class="stringliteral">&#39;/app/common/init.php&#39;</span>;</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;require_once <a class="code" href="../../d6/d75/init_8php.html#a9d247c19a0245a28a9363b9ded3df8e4">ADODB_PATH</a> . <span class="stringliteral">&#39;/adodb.inc.php&#39;</span>;</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;require_once <a class="code" href="../../de/dc4/settings_8dist_8php.html#af21c418e4c577deb3a9ea7299156ae35">$tolc_conf</a>[<span class="stringliteral">&#39;project_dir&#39;</span>] . <span class="stringliteral">&#39;/app/common/utils_db.php&#39;</span>;</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;require_once <a class="code" href="../../de/dc4/settings_8dist_8php.html#af21c418e4c577deb3a9ea7299156ae35">$tolc_conf</a>[<span class="stringliteral">&#39;project_dir&#39;</span>] . <span class="stringliteral">&#39;/app/common/utils.php&#39;</span>;</div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;</div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="comment">// get params</span></div>
<div class="line"><a name="l00026"></a><span class="lineno"><a class="code" href="../../d0/d3d/ajax__new__page_8php.html#aa6d6c9fbfa20cad1ecb26166fb5bb16c">   26</a></span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#aa6d6c9fbfa20cad1ecb26166fb5bb16c">$page_url</a> = $_POST[<span class="stringliteral">&#39;page_url&#39;</span>];</div>
<div class="line"><a name="l00027"></a><span class="lineno"><a class="code" href="../../d0/d3d/ajax__new__page_8php.html#ace7d5ca2414fbd4f411985155fe2f643">   27</a></span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#ace7d5ca2414fbd4f411985155fe2f643">$page_title</a> = htmlspecialchars($_POST[<span class="stringliteral">&#39;page_title&#39;</span>], ENT_QUOTES, <a class="code" href="../../d6/d75/init_8php.html#af5deb172ccf3910c031a23a46ed7e879">CONST_UTF8</a>);</div>
<div class="line"><a name="l00028"></a><span class="lineno"><a class="code" href="../../d0/d3d/ajax__new__page_8php.html#af3275005006cea4174b9c60706576b73">   28</a></span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#af3275005006cea4174b9c60706576b73">$www_templates_id</a> = $_POST[<span class="stringliteral">&#39;www_templates_id&#39;</span>];</div>
<div class="line"><a name="l00029"></a><span class="lineno"><a class="code" href="../../d0/d3d/ajax__new__page_8php.html#adffe3566fa44610a67a94146a30304ba">   29</a></span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#adffe3566fa44610a67a94146a30304ba">$date_start</a> = $_POST[<span class="stringliteral">&#39;date_start&#39;</span>];</div>
<div class="line"><a name="l00030"></a><span class="lineno"><a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a25a9fcc7a2f2f4888a50b6c56fd55d1c">   30</a></span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a25a9fcc7a2f2f4888a50b6c56fd55d1c">$parent_id</a> = $_POST[<span class="stringliteral">&#39;parent_id&#39;</span>];</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="comment">// connect to database</span></div>
<div class="line"><a name="l00033"></a><span class="lineno"><a class="code" href="../../d0/d3d/ajax__new__page_8php.html#aa8a5a87b9c1a6a0819b88447cbe41877">   33</a></span>&#160;<a class="code" href="../../d5/d3e/ajax__autocomplete__parent__title_8php.html#aa8a5a87b9c1a6a0819b88447cbe41877">$conn</a> = <a class="code" href="../../d2/d1c/utils__db_8php.html#a9130b08511e6b3e5efd303a8cb48b4e8">get_db_conn</a>(<a class="code" href="../../de/dc4/settings_8dist_8php.html#af21c418e4c577deb3a9ea7299156ae35">$tolc_conf</a>[<span class="stringliteral">&#39;dbdriver&#39;</span>]);</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="comment">// get current user id</span></div>
<div class="line"><a name="l00036"></a><span class="lineno"><a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a047170d6020a882807665812a27e2525">   36</a></span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a047170d6020a882807665812a27e2525">$sql</a> = <span class="stringliteral">&#39;SELECT id FROM www_users WHERE username=&#39;</span> . <a class="code" href="../../d5/d3e/ajax__autocomplete__parent__title_8php.html#aa8a5a87b9c1a6a0819b88447cbe41877">$conn</a>-&gt;qstr(<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a395f20d5378de643ef8d64e86d6bba9a">$_SESSION</a>[<span class="stringliteral">&#39;username&#39;</span>]);</div>
<div class="line"><a name="l00037"></a><span class="lineno"><a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a801399e74a9ffbd3985c323da20bb59e">   37</a></span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a801399e74a9ffbd3985c323da20bb59e">$rs</a> = <a class="code" href="../../d5/d3e/ajax__autocomplete__parent__title_8php.html#aa8a5a87b9c1a6a0819b88447cbe41877">$conn</a>-&gt;Execute(<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a047170d6020a882807665812a27e2525">$sql</a>);</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;<span class="keywordflow">if</span>(<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a801399e74a9ffbd3985c323da20bb59e">$rs</a> === <span class="keyword">false</span>) {</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;        trigger_error(<span class="stringliteral">&#39;Wrong SQL: &#39;</span> . <a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a047170d6020a882807665812a27e2525">$sql</a> . <span class="stringliteral">&#39; Error: &#39;</span> . <a class="code" href="../../d5/d3e/ajax__autocomplete__parent__title_8php.html#aa8a5a87b9c1a6a0819b88447cbe41877">$conn</a>-&gt;ErrorMsg(), E_USER_ERROR);</div>
<div class="line"><a name="l00040"></a><span class="lineno"><a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a2fef2a57694dba58d0bf17d40acfdad6">   40</a></span>&#160;} <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;        <a class="code" href="../../d9/d37/ajax__load__page__version_8php.html#a474a7ef24f527d87a414664d5aadc37f">$www_users_id</a> = <a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a801399e74a9ffbd3985c323da20bb59e">$rs</a>-&gt;fields[<span class="stringliteral">&#39;id&#39;</span>];</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;}</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;<span class="comment">// check URL max lenght</span></div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;<span class="keywordflow">if</span>(mb_strlen(<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#aa6d6c9fbfa20cad1ecb26166fb5bb16c">$page_url</a>) &gt; <a class="code" href="../../de/dc4/settings_8dist_8php.html#af21c418e4c577deb3a9ea7299156ae35">$tolc_conf</a>[<span class="stringliteral">&#39;pref_url_max_length&#39;</span>]) {</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;        print <a class="code" href="../../d5/dd6/gettext__missing_8php.html#a3c20d7b28b08b0ee319c8dffdc979b75">gettext</a>(<span class="stringliteral">&#39;Max length of URL is&#39;</span>) . <span class="charliteral">&#39; &#39;</span> . <a class="code" href="../../de/dc4/settings_8dist_8php.html#af21c418e4c577deb3a9ea7299156ae35">$tolc_conf</a>[<span class="stringliteral">&#39;pref_url_max_length&#39;</span>] . <span class="stringliteral">&#39;...&#39;</span>;</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;        exit;</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;}</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;<span class="comment">// check for valid URL</span></div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;<span class="keywordflow">if</span>(preg_match(<span class="stringliteral">&#39;/\040\040/&#39;</span>, <a class="code" href="../../d0/d3d/ajax__new__page_8php.html#aa6d6c9fbfa20cad1ecb26166fb5bb16c">$page_url</a>)) {</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;        print <a class="code" href="../../d5/dd6/gettext__missing_8php.html#a3c20d7b28b08b0ee319c8dffdc979b75">gettext</a>(<span class="stringliteral">&#39;Only one space allowed between words&#39;</span>) . <span class="stringliteral">&#39;...&#39;</span>;</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;        exit;</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;}</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;<span class="comment">// sanitize URL</span></div>
<div class="line"><a name="l00057"></a><span class="lineno"><a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a8ef64a2308933589ceeeb75b95cb02b7">   57</a></span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a8ef64a2308933589ceeeb75b95cb02b7">$url_length</a> = min(<a class="code" href="../../de/dc4/settings_8dist_8php.html#af21c418e4c577deb3a9ea7299156ae35">$tolc_conf</a>[<span class="stringliteral">&#39;pref_url_max_length&#39;</span>], <a class="code" href="../../d6/d75/init_8php.html#ac913e6c3da3790f32597e15e7471411b">CONST_URL_DB_MAXLENGTH</a>);</div>
<div class="line"><a name="l00058"></a><span class="lineno"><a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a4051266b6103672dbb03140aec5e9994">   58</a></span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a4051266b6103672dbb03140aec5e9994">$remove_accents</a> = <a class="code" href="../../de/dc4/settings_8dist_8php.html#af21c418e4c577deb3a9ea7299156ae35">$tolc_conf</a>[<span class="stringliteral">&#39;pref_url_remove_accents&#39;</span>];</div>
<div class="line"><a name="l00059"></a><span class="lineno"><a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a857d1c9b34992f955185d20c3241fd87">   59</a></span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a857d1c9b34992f955185d20c3241fd87">$convert_to_lower_case</a> = <a class="code" href="../../de/dc4/settings_8dist_8php.html#af21c418e4c577deb3a9ea7299156ae35">$tolc_conf</a>[<span class="stringliteral">&#39;pref_url_convert_to_lower_case&#39;</span>];</div>
<div class="line"><a name="l00060"></a><span class="lineno"><a class="code" href="../../d0/d3d/ajax__new__page_8php.html#ad98f1b0945b0e29c316b69e1ff69db92">   60</a></span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#ad98f1b0945b0e29c316b69e1ff69db92">$replace_space_between_words_with_dash</a> = <a class="code" href="../../de/dc4/settings_8dist_8php.html#af21c418e4c577deb3a9ea7299156ae35">$tolc_conf</a>[<span class="stringliteral">&#39;pref_url_replace_space_between_words_with_dash&#39;</span>];</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#aa6d6c9fbfa20cad1ecb26166fb5bb16c">$page_url</a> = <a class="code" href="../../d8/dfd/utils_8php.html#adef31fd3c624e3d6eadcc5a15a682969">sanitize_url</a>(<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#aa6d6c9fbfa20cad1ecb26166fb5bb16c">$page_url</a>, <a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a8ef64a2308933589ceeeb75b95cb02b7">$url_length</a>, <a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a4051266b6103672dbb03140aec5e9994">$remove_accents</a>, <a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a857d1c9b34992f955185d20c3241fd87">$convert_to_lower_case</a>, <a class="code" href="../../d0/d3d/ajax__new__page_8php.html#ad98f1b0945b0e29c316b69e1ff69db92">$replace_space_between_words_with_dash</a>);</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;<span class="comment">// check for valid URL</span></div>
<div class="line"><a name="l00064"></a><span class="lineno"><a class="code" href="../../d0/d3d/ajax__new__page_8php.html#ac1993a970d40fb76abf5e713d3b20671">   64</a></span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#ac1993a970d40fb76abf5e713d3b20671">$valid_url</a> = <a class="code" href="../../d8/dfd/utils_8php.html#adc3d2aaaf8242b0db6211c72e955b7c8">valid_url</a>(<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#aa6d6c9fbfa20cad1ecb26166fb5bb16c">$page_url</a>, <a class="code" href="../../d6/d75/init_8php.html#a4ac696a4afac23226b2ec54851c0915a">CONST_REGEX_SANITIZE_URL</a>, <a class="code" href="../../d6/d75/init_8php.html#a0692efa1015e864be063286f7c9cc6d4">CONST_REGEX_SANITIZE_URL_LEGACY</a>);</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;<span class="keywordflow">if</span>(!<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#ac1993a970d40fb76abf5e713d3b20671">$valid_url</a>) {</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;        print <a class="code" href="../../d5/dd6/gettext__missing_8php.html#a3c20d7b28b08b0ee319c8dffdc979b75">gettext</a>(<span class="stringliteral">&#39;Invalid URL&#39;</span>) . <span class="charliteral">&#39;.&#39;</span> . <span class="charliteral">&#39; &#39;</span> . <a class="code" href="../../d5/dd6/gettext__missing_8php.html#a3c20d7b28b08b0ee319c8dffdc979b75">gettext</a>(<span class="stringliteral">&#39;Valid URL may contain letters, digits, space and the characters&#39;</span>) . <span class="charliteral">&#39; &#39;</span> . <span class="stringliteral">&#39;.-_/&#39;</span>;</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;        exit;</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;}</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;<span class="comment">// check for unique URL</span></div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a047170d6020a882807665812a27e2525">$sql</a> = <span class="stringliteral">&#39;SELECT id from www_pages WHERE LOWER(url)=&#39;</span> . <a class="code" href="../../d5/d3e/ajax__autocomplete__parent__title_8php.html#aa8a5a87b9c1a6a0819b88447cbe41877">$conn</a>-&gt;qstr(mb_strtolower(<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#aa6d6c9fbfa20cad1ecb26166fb5bb16c">$page_url</a>));</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a801399e74a9ffbd3985c323da20bb59e">$rs</a> = <a class="code" href="../../d5/d3e/ajax__autocomplete__parent__title_8php.html#aa8a5a87b9c1a6a0819b88447cbe41877">$conn</a>-&gt;Execute(<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a047170d6020a882807665812a27e2525">$sql</a>);</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;<span class="keywordflow">if</span>(<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a801399e74a9ffbd3985c323da20bb59e">$rs</a> === <span class="keyword">false</span>) {</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;        trigger_error(<span class="stringliteral">&#39;Wrong SQL: &#39;</span> . <a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a047170d6020a882807665812a27e2525">$sql</a> . <span class="stringliteral">&#39; Error: &#39;</span> . <a class="code" href="../../d5/d3e/ajax__autocomplete__parent__title_8php.html#aa8a5a87b9c1a6a0819b88447cbe41877">$conn</a>-&gt;ErrorMsg(), E_USER_ERROR);</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;} <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;        <span class="keywordflow">if</span>(<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a801399e74a9ffbd3985c323da20bb59e">$rs</a>-&gt;RecordCount() != 0) {</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;                print <a class="code" href="../../d5/dd6/gettext__missing_8php.html#a3c20d7b28b08b0ee319c8dffdc979b75">gettext</a>(<span class="stringliteral">&#39;URL already exists&#39;</span>) . <span class="stringliteral">&#39;...&#39;</span>;</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;                exit;</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;        }</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;}</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;<span class="comment">// check valid datetime</span></div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#adffe3566fa44610a67a94146a30304ba">$date_start</a> = trim(<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#adffe3566fa44610a67a94146a30304ba">$date_start</a>);</div>
<div class="line"><a name="l00085"></a><span class="lineno"><a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a8ada2a3347c63cf1058071243b769c6c">   85</a></span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a8ada2a3347c63cf1058071243b769c6c">$user_tz</a> = <a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a395f20d5378de643ef8d64e86d6bba9a">$_SESSION</a>[<span class="stringliteral">&#39;user_timezone&#39;</span>];</div>
<div class="line"><a name="l00086"></a><span class="lineno"><a class="code" href="../../d0/d3d/ajax__new__page_8php.html#ab74db288cd92349906022ba161ff1043">   86</a></span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#ab74db288cd92349906022ba161ff1043">$user_df_php_datetime</a> = <a class="code" href="../../d6/d75/init_8php.html#a5fdabd46dd0a8f5395fbca2f2de9302d">$a_date_format</a>[<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a395f20d5378de643ef8d64e86d6bba9a">$_SESSION</a>[<span class="stringliteral">&#39;user_dateformat&#39;</span>]][<span class="stringliteral">&#39;php_datetime&#39;</span>];</div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;<span class="keywordflow">if</span>(!<a class="code" href="../../d8/dfd/utils_8php.html#aaafe5bfeb6c88ccc33990612b77a2199">isValidDateTimeString</a>(<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#adffe3566fa44610a67a94146a30304ba">$date_start</a>, <a class="code" href="../../d0/d3d/ajax__new__page_8php.html#ab74db288cd92349906022ba161ff1043">$user_df_php_datetime</a>, <a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a8ada2a3347c63cf1058071243b769c6c">$user_tz</a>)) {</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;        print <a class="code" href="../../d5/dd6/gettext__missing_8php.html#a3c20d7b28b08b0ee319c8dffdc979b75">gettext</a>(<span class="stringliteral">&#39;Invalid date&#39;</span>) . <span class="stringliteral">&#39;...&#39;</span>;</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;        exit;</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;}</div>
<div class="line"><a name="l00091"></a><span class="lineno"><a class="code" href="../../d0/d3d/ajax__new__page_8php.html#aaf8eff284915b9fff71a3d7d0993ba8b">   91</a></span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#aaf8eff284915b9fff71a3d7d0993ba8b">$date_start_encoded</a> = <a class="code" href="../../d8/dfd/utils_8php.html#a06e96ccdcb8d9d23fdf1957d17276a72">date_encode</a>(<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#adffe3566fa44610a67a94146a30304ba">$date_start</a>, <a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a8ada2a3347c63cf1058071243b769c6c">$user_tz</a>, <a class="code" href="../../d0/d3d/ajax__new__page_8php.html#ab74db288cd92349906022ba161ff1043">$user_df_php_datetime</a>);</div>
<div class="line"><a name="l00092"></a><span class="lineno"><a class="code" href="../../d0/d3d/ajax__new__page_8php.html#ae9fc7a28f9bdbaf0d1d2fdcc086b5582">   92</a></span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#ae9fc7a28f9bdbaf0d1d2fdcc086b5582">$date_start_sql</a> = <a class="code" href="../../d5/d3e/ajax__autocomplete__parent__title_8php.html#aa8a5a87b9c1a6a0819b88447cbe41877">$conn</a>-&gt;qstr(<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#aaf8eff284915b9fff71a3d7d0993ba8b">$date_start_encoded</a>);</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;<span class="comment">// proceed to insert</span></div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;<a class="code" href="../../d5/d3e/ajax__autocomplete__parent__title_8php.html#aa8a5a87b9c1a6a0819b88447cbe41877">$conn</a>-&gt;BeginTrans();</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;</div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;<span class="comment">// insert new page</span></div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a047170d6020a882807665812a27e2525">$sql</a> = <span class="stringliteral">&#39;INSERT INTO www_pages &#39;</span> .</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;        <span class="stringliteral">&#39;(url,title,parent_id) &#39;</span> .</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;        <span class="stringliteral">&#39;VALUES (&#39;</span> .</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;        <a class="code" href="../../d5/d3e/ajax__autocomplete__parent__title_8php.html#aa8a5a87b9c1a6a0819b88447cbe41877">$conn</a>-&gt;qstr(<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#aa6d6c9fbfa20cad1ecb26166fb5bb16c">$page_url</a>) . <span class="charliteral">&#39;,&#39;</span> .</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;        <a class="code" href="../../d5/d3e/ajax__autocomplete__parent__title_8php.html#aa8a5a87b9c1a6a0819b88447cbe41877">$conn</a>-&gt;qstr(<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#ace7d5ca2414fbd4f411985155fe2f643">$page_title</a>) . <span class="charliteral">&#39;,&#39;</span> .</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;        <a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a25a9fcc7a2f2f4888a50b6c56fd55d1c">$parent_id</a> .</div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;        <span class="charliteral">&#39;)&#39;</span>;</div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;<span class="keywordflow">if</span>(<a class="code" href="../../d5/d3e/ajax__autocomplete__parent__title_8php.html#aa8a5a87b9c1a6a0819b88447cbe41877">$conn</a>-&gt;Execute(<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a047170d6020a882807665812a27e2525">$sql</a>) === <span class="keyword">false</span>) {</div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;        $err = <a class="code" href="../../d5/d3e/ajax__autocomplete__parent__title_8php.html#aa8a5a87b9c1a6a0819b88447cbe41877">$conn</a>-&gt;ErrorMsg();</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;        <a class="code" href="../../d5/d3e/ajax__autocomplete__parent__title_8php.html#aa8a5a87b9c1a6a0819b88447cbe41877">$conn</a>-&gt;RollbackTrans();</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;        trigger_error(<span class="stringliteral">&#39;Wrong SQL: &#39;</span> . <a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a047170d6020a882807665812a27e2525">$sql</a> . <span class="stringliteral">&#39; Error: &#39;</span> . $err, E_USER_ERROR);</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;} <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;        <a class="code" href="../../db/d3f/ajax__addnew__page__version_8php.html#a2ee0dbecb1c2b92cf425284093e0542d">$www_pages_id</a> = <a class="code" href="../../d5/d3e/ajax__autocomplete__parent__title_8php.html#aa8a5a87b9c1a6a0819b88447cbe41877">$conn</a>-&gt;Insert_ID();</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;}</div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;</div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;<span class="comment">// insert new template for new inserted page</span></div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a047170d6020a882807665812a27e2525">$sql</a> = <span class="stringliteral">&#39;INSERT INTO www_page_templates &#39;</span> .</div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;        <span class="stringliteral">&#39;(www_pages_id,www_templates_id,date_start) &#39;</span> .</div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;        <span class="stringliteral">&#39;VALUES (&#39;</span> .</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;        <a class="code" href="../../db/d3f/ajax__addnew__page__version_8php.html#a2ee0dbecb1c2b92cf425284093e0542d">$www_pages_id</a> . <span class="charliteral">&#39;,&#39;</span> .</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;        <a class="code" href="../../d0/d3d/ajax__new__page_8php.html#af3275005006cea4174b9c60706576b73">$www_templates_id</a> . <span class="charliteral">&#39;,&#39;</span> .</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;        <a class="code" href="../../d0/d3d/ajax__new__page_8php.html#ae9fc7a28f9bdbaf0d1d2fdcc086b5582">$date_start_sql</a> .</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;        <span class="charliteral">&#39;)&#39;</span>;</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;<span class="keywordflow">if</span>(<a class="code" href="../../d5/d3e/ajax__autocomplete__parent__title_8php.html#aa8a5a87b9c1a6a0819b88447cbe41877">$conn</a>-&gt;Execute(<a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a047170d6020a882807665812a27e2525">$sql</a>) === <span class="keyword">false</span>) {</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;        $err = <a class="code" href="../../d5/d3e/ajax__autocomplete__parent__title_8php.html#aa8a5a87b9c1a6a0819b88447cbe41877">$conn</a>-&gt;ErrorMsg();</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;        <a class="code" href="../../d5/d3e/ajax__autocomplete__parent__title_8php.html#aa8a5a87b9c1a6a0819b88447cbe41877">$conn</a>-&gt;RollbackTrans();</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;        trigger_error(<span class="stringliteral">&#39;Wrong SQL: &#39;</span> . <a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a047170d6020a882807665812a27e2525">$sql</a> . <span class="stringliteral">&#39; Error: &#39;</span> . $err, E_USER_ERROR);</div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;}</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;</div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;<a class="code" href="../../d5/d3e/ajax__autocomplete__parent__title_8php.html#aa8a5a87b9c1a6a0819b88447cbe41877">$conn</a>-&gt;CommitTrans();</div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;</div>
<div class="line"><a name="l00129"></a><span class="lineno"><a class="code" href="../../d0/d3d/ajax__new__page_8php.html#a395f20d5378de643ef8d64e86d6bba9a">  129</a></span>&#160;$_SESSION[<span class="stringliteral">&#39;url&#39;</span>] = <a class="code" href="../../d0/d3d/ajax__new__page_8php.html#aa6d6c9fbfa20cad1ecb26166fb5bb16c">$page_url</a>;</div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;?&gt;</div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="../../dir_d422163b96683743ed3963d4aac17747.html">app</a></li><li class="navelem"><a class="el" href="../../dir_04bb458943ba1ea9da78306bf6170bdc.html">admin</a></li><li class="navelem"><a class="el" href="../../dir_4ccca2a3daaab7d2ed8b9d329364fc44.html">new_page</a></li><li class="navelem"><a class="el" href="../../d0/d3d/ajax__new__page_8php.html">ajax_new_page.php</a></li>
    <li class="footer">Generated on Fri Aug 31 2012 22:06:31 for Tolc by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="../../doxygen.png" alt="doxygen"/></a> 1.8.2 </li>
  </ul>
</div>
</body>
</html>
